package com.wly.ui.panel
{
	import com.wly.datapool.DataPool;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class SettingPanel extends Sprite
	{
		private var _mcBgSound:MovieClip;
		private var _mcEffectSound:MovieClip;
		
		public function SettingPanel()
		{
			super();
			initChilds();
			initStats();
		}
		
		private function initChilds():void
		{
			_mcBgSound = getChildByName("mcBgSound") as MovieClip;
			_mcEffectSound = getChildByName("mcEffectSound") as MovieClip;
			
			_mcBgSound.stop();
			_mcEffectSound.stop();
			
			_mcBgSound.addEventListener(MouseEvent.CLICK, onSwitchBgSoundSetting);
			_mcEffectSound.addEventListener(MouseEvent.CLICK, onSwitchEffectSoundSetting);
		}
		
		private function initStats():void
		{
			var showFrame:int = DataPool.getInstance().setting.bgSoundOff?2:1;
			_mcBgSound.gotoAndStop(showFrame);
			
			var showFrame:int = DataPool.getInstance().setting.effectSoundOff?2:1;
			_mcEffectSound.gotoAndStop(showFrame);
		}
		
		private function onSwitchBgSoundSetting(e:MouseEvent):void
		{
			DataPool.getInstance().setting.bgSoundOff = !DataPool.getInstance().setting.bgSoundOff;
			var showFrame:int = DataPool.getInstance().setting.bgSoundOff?2:1;
			_mcBgSound.gotoAndStop(showFrame);
		}
		
		private function onSwitchEffectSoundSetting(e:MouseEvent):void
		{
			DataPool.getInstance().setting.effectSoundOff = !DataPool.getInstance().setting.effectSoundOff;
			var showFrame:int = DataPool.getInstance().setting.effectSoundOff?2:1;
			_mcEffectSound.gotoAndStop(showFrame);
		}
	}
}